package br.com.sisdoctor.view.bean.util.tag;


import java.io.IOException;

import javax.faces.application.NavigationHandler;
import javax.faces.component.FacesComponent;
import javax.faces.component.UIComponentBase;
import javax.faces.context.FacesContext;

@FacesComponent(value = "validaPermissao")
public class ValidaPermissao extends UIComponentBase {

	@Override
	public String getFamily() {
		return "custom";
	}


	@Override
	public void encodeEnd(FacesContext context) throws IOException {

		boolean usuarioLoged = (Boolean) this.getAttributes().get("test");
		if (!usuarioLoged){
			 NavigationHandler navigationHandler = FacesContext.getCurrentInstance().getApplication().getNavigationHandler();  
			 navigationHandler.handleNavigation(FacesContext.getCurrentInstance(), null, "pretty:login"); 
		}
	}

}

